import { createRouter, createWebHashHistory } from "vue-router"
import Index from "@/pages/index.vue"

const routes = [
  {
    path: "/",
    name: "Index",
    component: Index,
    meta: { title: "AI Chat" }
  }
]
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

// 全局前置守卫 - 设置页面标题
router.beforeEach((to, from, next) => {
  // 如果路由定义了 meta.title，则设置为文档标题
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router
